<?php
$h_data = (isset($h_data)) ? $h_data : '';
$m_data = (isset($m_data)) ? $m_data : '';
$f_data = (isset($f_data)) ? $f_data : '';

$login_status = array(
    'username' => $this->session->userdata('username'),
    'is_logged_in' => $this->session->userdata('is_logged_in'),
    'userid' => $this->session->userdata('userid'),
    'user_type' => $this->session->userdata('user_type')
);
$h_data['user_status'] = $login_status;
$h_data['_user_type'] = $this->session->userdata('user_type');

switch ($main_content)
{
    case 'web_view':
        $h_data['_marker'] = 'web';
        break;
    case 'image_view':
        $h_data['_marker'] = 'image';
        break;
    case 'stats_view':
        $h_data['_marker'] = 'stats';
        break;
    case 'usercp_view':
        $h_data['_marker'] = 'login';
    default:
        $h_data['_marker'] = 'web';
        break;
}
$username = $this->session->userdata('username');
$msg_query = $this->db->query("SELECT `to_user`,`read` FROM message WHERE to_user = '$username' AND `read` = 0;");
if ($msg_query->num_rows > 0) //Check unread Messages
{
    $num_msg = $msg_query->num_rows;
    if ($num_msg >= 1) {
        $num_msg = '<span onclick="show_msg()" id="msg_counter">' . $num_msg . '</span>' . '  message.';
    }
    else
    {
        '<span onclick="show_msg()" id="msg_counter">' . $num_msg . '</span>' . '  messages.';
    }
}
else
{
    $num_msg = 'No Message';
}
$h_data['num_msg'] = $num_msg;

$this->load->view('includes/header', $h_data);
$this->load->view($main_content, $m_data);
$this->load->view('includes/footer', $f_data);